/**
 * jaroverlay-maven-plugin : add remove replace content and repackage nested archives
 * 
 * Copyright (C) 2008  Paul Merlin
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.n0pe.jaroverlay.config;


import java.io.StringWriter;
import org.apache.commons.lang.StringUtils;


/**
 * Represent a source artifact in the plugin configuration.
 * 
 * @author Paul Merlin <eskatos@n0pe.org>
 */
public class Source {


    private String groupId;


    private String artifactId;


    private String version;


    private String type;


    private String classifier;


    public String getArtifactId() {
        return artifactId;
    }


    public String getGroupId() {
        return groupId;
    }


    public String getType() {
        return type;
    }


    public String getVersion() {
        return version;
    }


    public String getClassifier() {
        return classifier;
    }


    public String toString() {
        StringWriter sw = new StringWriter();
        sw.append((groupId == null ? "null" : groupId)).append(":");
        sw.append((artifactId == null ? "null" : artifactId)).append(":");
        sw.append((classifier == null ? "null" : classifier)).append(":");
        sw.append((type == null ? "null" : type)).append(":");
        sw.append((version == null ? "null" : version));
        return sw.toString();
    }


    /**
     * Used during the plugin configuration check.
     * 
     * @return True if the source is valid, else return false;
     */
    public boolean isValid() {
        return !(StringUtils.isEmpty(groupId) || StringUtils.isEmpty(artifactId) ||
                StringUtils.isEmpty(type) || StringUtils.isEmpty(version));
    }


}
